package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.dto.DishDto;
import com.itheima.exception.CustomException;
import com.itheima.service.DishService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tang
 * @date 2022/11/23 16:43
 */
@Slf4j
@RestController
@RequestMapping("/dish")
public class DishController {
    @Autowired
    private DishService dishService;

    @PostMapping
    public R<String> add(@RequestBody DishDto dishDto) {
        log.info("dishDto: {}", dishDto);
        if (dishDto == null) {
            throw new CustomException("查询失败");
        }
        return dishService.add(dishDto);
    }
}
